home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 13 / CU Amiga Magazine's Super CD-ROM 13 (1997)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1997-08].iso / C / ConfigPC2Amiga < prev    next >
Text File  |  1997-03-27  |  15KB  |  429 lines

  1. ; Configuration script for the PC2Am program
  2.  
  3. ;Indicator types
  4. (set ISTR0 "None")
  5. (set ISTR1 "LED")
  6. (set ISTR2 "Gopher-like")
  7. (set ISTR3 "Background")
  8. ;(set ISTR4 "Mouse")
  9.  
  10. ;Speeds
  11. (set SPEED0 "1200")
  12. (set SPEED1 "2400")
  13. (set SPEED2 "4800")
  14. (set SPEED3 "9600")
  15. (set SPEED4 "19200")
  16. (set SPEED5 "38400")
  17. (set SPEED6 "57600")
  18. (set SPEED7 "115200")
  19.  
  20. ;Cables
  21. (set CABLE0 "LapLink 4W")
  22. (set CABLE1 "Special 8W")
  23.  
  24.  
  25.  
  26. (procedure EditConfig
  27.  
  28.   ; Set transfer type
  29.   (set OldXferType XferType)
  30.   (set XferType
  31.     (askchoice 
  32.       (prompt "Select port to use")
  33.       (choices "Serial" "Parallel")
  34.       (default XferType)
  35.       (help 
  36.         "You have to select whether you want to use parallel or serial transfer. "
  37.         "It depends on the cable you have. For serial, you need serial null-modem "
  38.         "cable, for parallel LapLink cable, sometimes called parallel null-modem. "
  39.         "You can also build a special parallel cable and get faster transfers, "
  40.         "but this needs hardware experience. More info about cables can be found "
  41.         "in PC2Am.guide, section 'How to run program/Cables.'.\n"
  42.         "Parallel transfers are faster, but there are strong limitations in the "
  43.         "cable length. Over a serial, you can use multiserial card. There are "
  44.         "also parallel cards, but I din't get any technical info about it."
  45.       )
  46.     )
  47.   )
  48.  
  49.   (if (= XferType 1)
  50.     (
  51.       (set Device "PC2AmParallel.device")
  52.       (set Timeout 10)
  53.       (set Unit 0)
  54.       (set Flags
  55.         (askchoice
  56.           (prompt "Which cable do you use")
  57.           (choices CABLE0 CABLE1)
  58.           (default Flags)
  59.           (help
  60.            "\n"
  61.            "LAPLINK 4W is standard parallel null-modem cable, using four data wires "
  62.            "in each direction.\n\n"
  63.            "SPECIAL 8W cable cannot be bought, you must made it. But then you can "
  64.            "get faster transfer rates. It uses eight lines to transfer data and "
  65.            "needs Enhanced Parallel Port (EPP) or ECP port.\n\n"
  66.            "For more info and wiring diagrams see "
  67.            "PC2Am.guide, section HowToRunProgram/Cables."
  68.           )
  69.         )
  70.       )
  71.     )
  72.   )
  73.  
  74.   (if (= XferType 0)
  75.     (
  76.  
  77.       ; Set device
  78.       (if (<> XferType OldXferType)
  79.         (set Device "serial.device")
  80.       )
  81.  
  82.       (set DevOK 0)
  83.       (until (= DevOK 1)
  84.         (set DefDev ("DEVS:/%s" Device))
  85.         (set Device
  86.           (fileonly
  87.             (askfile
  88.               (prompt "Select device you want to use. For parallel transfer "
  89.                       "select PC2AmPar.device. Click on HELP for further details")
  90.               (help 
  91.                 "You have to select device to communicate via. It will mostly be \"serial.device\" "
  92.                 "but you can also use \"artser.device\" etc. But remember that some devices don't "
  93.                 "support the Break() function (baudbandit.device), so they cannot be "
  94.                 "used.\n\nFor parallel transfer is used device called PC2AmParallel.device."
  95.               )
  96.               (default DefDev)
  97.             )
  98.           )
  99.         )
  100.  
  101.         (set DevOK 1)
  102.         (if (= Device "parallel.device")
  103.           (
  104.             (message
  105.               "PC2Amiga does not use standard parallel.device for the transfer. "
  106.               "For parallel transfers it uses its own device called 'PC2AmParallel.device'. "
  107.               "If you wanted to set parallel transfer use this one. Now you will have to select "
  108.               "the device again.\n"
  109.               "Better way is to select parallel transfer (in previous requester)."
  110.             )
  111.             (set DevOK 0)
  112.           )
  113.         )
  114.       )
  115.  
  116.       ; Set unit
  117.       (set Unit
  118.         (asknumber
  119.           (prompt "Select unit of the device")
  120.           (help "This will be mostly zero. You will have to change it only if you use a multiserial card.")
  121.           (default Unit)
  122.         )
  123.       )
  124.  
  125.       ; Set Flags
  126.       (set Flags
  127.         (asknumber
  128.           (prompt "Select open flags of the device")
  129.           (help "This will be mostly zero. You will have to change it only if you use a multiserial card.")
  130.           (range -2147483648 2147483647)
  131.           (default Flags)
  132.         )
  133.       )
  134.  
  135.       ; Set baud rate
  136.       ; Find baud code
  137.       (set BaudCode 0)
  138.       (while (AND (> BaudRate (+ 0 (select BaudCode SPEED0 SPEED1 SPEED2 SPEED3 SPEED4 SPEED5 SPEED6 SPEED7))) (< BaudCode 7))
  139.         (set BaudCode (+ BaudCode 1))
  140.       )
  141.       (set BaudRate
  142.         (+ 0
  143.           (select 
  144.             (askchoice 
  145.               (prompt "Select baud rate")
  146.               (choices SPEED0 SPEED1 SPEED2 SPEED3 SPEED4 SPEED5 SPEED6 SPEED7)
  147.               (default BaudCode)
  148.               (help 
  149.               "You have to select baud rate to communicate on. It is important to set "
  150.               "this baudrate to the same value on both Amiga and PC. Selecting too big "
  151.               "baudrate may cause infunctionality, low baudrates lowers transfer speed. "
  152.               "If you have at least A500 and 386SX/40, you can choose 57600."
  153.               )
  154.             )
  155.             SPEED0 SPEED1 SPEED2 SPEED3 SPEED4 SPEED5 SPEED6 SPEED7
  156.           )
  157.         )
  158.       )
  159.  
  160.       ;Set timeout
  161.       (set Timeout
  162.         (asknumber
  163.           (prompt "Set timeout\nNote, that it is in TENTHS of second.")
  164.           (help
  165.             "Timeout is the time, after which Amiga will try to restore "
  166.             "send PC a break, to make it reply packet etc. Good value is about"
  167.             "20 (2 secs) or a little bit more. High values do not have sense, "
  168.             "because there will be spent much time in waiting for PC. But setting "
  169.             "it too small may cause many timeouts when working with slower device "
  170.             "(floppy) or on small baud rates.\n\n"
  171.             "When you use parallel transfer, you should set this value to 100 or similar value."
  172.           )
  173.           (default Timeout)
  174.         )
  175.       )
  176.     )
  177.   )
  178.  
  179.   ;Set MaxTransfer
  180.   (set MaxTransfer
  181.     (asknumber
  182.       (prompt "Set maximal length of a packet.")
  183.       (range 312 8192)
  184.       (help
  185.         "Here you can set the maximal length of packet, that is transfered via "
  186.         "serial (parallel) line. Note that it is used only for sending files, "
  187.         "because other packets (open, ...) are only about 20 bytes long. So set "
  188.         "it to a lower value only when you can list directories well (listing main "
  189.         "PC: directory takes shorter packets that listing "true" directory on PC). "
  190.         "Usually, you can keep this value at least 4096 or even 8192."
  191.       )
  192.       (default MaxTransfer)
  193.     )
  194.   )
  195.  
  196.   ; Set if we want to pretend SetComment
  197.   (set PretendSCom 0)
  198.   (if (>= HighCyl 16)
  199.     (set PretendSCom 1)
  200.   )
  201.   (set PretendSCom
  202.     (askoptions
  203.       (prompt "Can PC2Amiga pretend SetComment() was succesfull ?")
  204.       (choices "Do pretend")
  205.       (default PretendSCom)
  206.       (help
  207.         "MS-DOS filesystem does not support file comments, so PC2Amiga doesn't "
  208.         "support it too and returns 'Action not known'. But some disk managers "
  209.         "sets comment of file when copying and puts up a requester when they "
  210.         "got error from filesystem, which may be very annoying. If you turn "
  211.         "on this option, PC2Amiga will answer 'OK' to SetComment() requests "
  212.         "like it successfuly set the comment, although it didn't do anything."
  213.       )
  214.     )
  215.   )
  216.  
  217.   ;Set progress indicator
  218.   (set IndicType
  219.     (askchoice 
  220.       (prompt "Select progress indicator type")
  221.       (choices ISTR0 ISTR1 ISTR2 ISTR3)
  222.       (default IndicType)
  223.       (help 
  224.         "Progress indicator is something that tells you the communication is "
  225.         "still working (data are transfering). Here's a description of supported "
  226.         "types:\n\n"
  227.         "NONE - No indicator will be used\n\n"        
  228.         "LED - Power LED brightness will be turned after sending each packet. "
  229.         "So when communication works, you will see LED flashing. But it may confuse "
  230.         "you, because it looks like you have been visited by a guru (system crash)."
  231.         "It may also interfere with a music playing program, because turning LED "
  232.         "turns also ON/OFF audio filter.\n\n"
  233.         "GOPHER-LIKE - In the PC2Amiga commodity window, there's a square, in which "
  234.         "you will see rotating line. But you have to popup PC2Amiga to see it, so you "
  235.         "cannot look at it all the time.\n\n"
  236.         "BACKGROUND - After sending every packet, background flashes. Maybe good for "
  237.         "some people, but for me it is too \"hard\" indication.\n\n"
  238. ;        "MOUSE - Mouse will flash as when unpacking by PowerPacker."
  239.       )
  240.     )
  241.   )
  242.  
  243.   ; Hotkey qualifier
  244.   (set HotKeyQ
  245.     (askoptions
  246.       (prompt "Choose qualifiers for commodity hotkey. If you don't select any, hotkey will be disabled.")
  247.       (choices "CTRL" "LALT" "RALT" "LSHIFT" "RSHIFT" "LCOMMAND" "RCOMMAND")
  248.       (default HotKeyQ)
  249.       (help 
  250.         "PC2Amiga window can be now popped up by a hotkey. "
  251.         "Here you select hotkey 'shifting'. In the next requester "
  252.         "you will select the key itself."
  253.       )
  254.     )
  255.   )
  256.  
  257.   (set HotKeyC
  258.     (askstring
  259.       (prompt "Enter KEY for the hotkey {shifting has been selected "
  260.               "before.} Only first char is considered."
  261.       )
  262.       (default HotKeyC)
  263.       (help "This is the hotkey that the PC2Amiga window will open on.")
  264.     )
  265.   )
  266.  
  267.   (set MaxErr (BITAND HighCyl 15))
  268.   (if (= MaxErr 0) ((set MaxErr 4)))
  269.   (set MaxErr
  270.     (asknumber
  271.       (prompt
  272.         "Choose number of errors to popup error requester.\n"
  273.         "Set it to 0 for no requester.\n"
  274.         "Do not change if you don't have any idea what is it for !"
  275.       )
  276.       (range 0 14)
  277.       (help
  278.         "When PC2Amiga cannot transfer packet for a long time, it pops up "
  279.         "a requester informing user there is some problem. It is for new "
  280.         "users, but it may be useful also in other situations.\n"
  281.         "In this dialog, you set the number of fails to popup this requester. "
  282.         "When you set it to 0 for no requests. "
  283.       )
  284.       (default (- MaxErr 1))
  285.     )
  286.   )
  287.   (set MaxErr (+ MaxErr 1))
  288.   
  289.   (set Priority
  290.     (asknumber
  291.       (range -128 127)
  292.       (prompt
  293.         "Set task priority for pc2amiga-handler. Help will tell you what is "
  294.         "this for."
  295.       )
  296.       (help
  297.         "If you use PC2Amiga via parallel, you may be confused that it almost "
  298.         "freezes your system while it is transfering. Especially some people "
  299.         "running BBSes and having some files on PC hated it.\n"
  300.         "By default, PC2Amiga has priority of 5 so there is no big danger it will be "
  301.         "interrupted while transfering, which could cause timeout. But if you "
  302.         "want to use your Amiga while transferring, you may set this to 0 or "
  303.         "-1. Normal programs will run OK. But when there will be heavy system "
  304.         "load, PC2Amiga will be unable to transfer.\n"
  305.         "Modify this value only when PC2Amiga is running OK on your machine and "
  306.         "you have real reasons to do it."
  307.       )
  308.       (default Priority)
  309.     )
  310.   )
  311. )
  312.  
  313. ; /***********************\
  314. ; *                       *
  315. ; *  Program starts here  *
  316. ; *                       *
  317. ; \***********************/
  318.  
  319. (if (<= (getversion (resident)) (* 37 65536))
  320.   (abort "Sorry, this script works only for systems 2.1 and later (kickstart version 37+)")
  321. )
  322.  
  323. (if (= (exists "c:GetPCSpecs") 0)
  324.   (abort "Cannot find command 'c:GetPCSpecs'. If you haven't installed PC2Amiga yet, you must do it before running this configuration script.")
  325. )
  326.  
  327. (if (= (exists "c:SetPCSpecs") 0)
  328.   (abort "Cannot find command 'c:SetPCSpecs'. If you haven't installed PC2Amiga yet, you must do it before running this configuration script.")
  329. )
  330.  
  331. (user 2)
  332.  
  333. (set FileName 
  334.   (askfile
  335.     (prompt "Please enter where you have installed the device specification file (\"PC\").")
  336.     (help
  337.       "There's a device specification file (called \"PC\"), which also contains "
  338.       "configuration data. Configuration script needs to know where it is to change "
  339.       "it. It should be either in the SYS:Storage/DOSDrivers or DEVS:DOSDrivers directory."
  340.     )
  341.     (default "SYS:Storage/DOSDrivers/PC")
  342.   )
  343. )
  344.  
  345. (if (= (exists FileName) 0)
  346.   (abort "The file you have entered does not exist !")
  347. )
  348.  
  349. (run ("GetPCSpecs %s" FileName))
  350.  
  351. ; Get original values
  352. (set Device (getenv "P2A_DEVICE"))
  353. (set Unit (+ 0 (getenv "P2A_UNIT")))
  354. (set Flags (+ 0 (getenv "P2A_FLAGS")))
  355. (set BaudRate (+ 0 (getenv "P2A_BAUD")))
  356. (set MaxTransfer (+ 0 (getenv "P2A_MAXTRANSFER")))
  357. (set Timeout (+ 0 (getenv "P2A_TIMEOUT")))
  358. (set HFlags (+ 0 (getenv "P2A_BLOCKSPERTRACK")))
  359. (set LowCyl (+ 0 (getenv "P2A_LOWCYL")))
  360. (set HighCyl (+ 0 (getenv "P2A_HIGHCYL")))
  361. (set IndicType (BITAND HFlags 7))
  362. (set HotKeyQ (/ (BITAND LowCyl $F00) $100))
  363. (set HotKeyC (getenv "P2A_HOTKEY"))
  364. (set Priority (+ 0 (getenv "P2A_PRIORITY")))
  365.  
  366. (set XferType (= Device "PC2AmParallel.device"))
  367.  
  368. (until
  369.   (= Result 1)
  370.   (EditConfig)
  371.   ; Set some vars
  372.   (set TSecs (/ Timeout 10))
  373.   (set TTent (- Timeout (* TSecs 10)))
  374.   (set Result 
  375.     (if (= XferType 1)
  376.       (
  377.         (askbool
  378.           (prompt
  379.             "Confirm settings:\n\n"
  380.             ("Using PARALLEL port\nCable: %s\n" (select Flags CABLE0 CABLE1))
  381.             ("Indicator: %s\n" (select IndicType ISTR0 ISTR1 ISTR2 ISTR3))
  382.           )
  383.           (help "Script asks you to confirm your selection.")
  384.         )
  385.       )
  386.       (
  387.         (askbool
  388.           (prompt
  389.             "Confirm settings:\n\nUsing SERIAL port\n"
  390.             ("Device: %s\nUnit: %ld\nFlags: %ld\nBaudRate: %ld\nTimeout: %ld.%lds\n" Device Unit Flags BaudRate TSecs TTent)
  391.             ("Indicator: %s\n" (select IndicType ISTR0 ISTR1 ISTR2 ISTR3))
  392.           )
  393.           (help "Script asks you to confirm your selection.")
  394.         )
  395.       )
  396.     )
  397.   )
  398. )
  399.  
  400.  
  401. ; Copy values to env vars
  402. (set HFlags IndicType)
  403. (set LowCyl (* HotKeyQ $100))
  404. (set HighCyl (+ MaxErr (* 16 PretendSCom)))
  405. (textfile (dest "ENV:P2A_DEVICE") (append Device))
  406. (textfile (dest "ENV:P2A_UNIT") (append Unit))
  407. (textfile (dest "ENV:P2A_FLAGS") (append Flags))
  408. (textfile (dest "ENV:P2A_BAUD") (append BaudRate))
  409. (textfile (dest "ENV:P2A_MAXTRANSFER") (append MaxTransfer))
  410. (textfile (dest "ENV:P2A_TIMEOUT") (append Timeout))
  411. (textfile (dest "ENV:P2A_BLOCKSPERTRACK") (append HFlags))
  412. (textfile (dest "ENV:P2A_LOWCYL") (append LowCyl))
  413. (textfile (dest "ENV:P2A_HIGHCYL") (append HighCyl))
  414. (textfile (dest "ENV:P2A_HOTKEY") (append HotKeyC))
  415. (textfile (dest "ENV:P2A_PRIORITY") (append Priority))
  416.  
  417. (run ("SetPCSpecs %s T:PC" FileName))
  418.  
  419. (copyfiles
  420.   (source "t:PC")
  421.   (dest (pathonly FileName))
  422. )
  423.  
  424.  
  425. (exit "\n\nDON'T FORGET TO SETUP ALSO THE PC PART\n(USING THE \"PC2AMCFG.EXE\" PROGRAM)")
  426.  
  427. (welcome)
  428.  
  429.